home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
_INTINBO.PRG
< prev
next >
Wrap
Text File
|
1993-05-04
|
3KB
|
120 lines
FUNCTION _IntInBox
PARAMETERS pn_row, pn_col, pc_prompt, pn_default, pn_low, pn_high
*---------------------------------------------------------------------
* NAME
* _IntInBox - Get an integer value in a box
*
* DESCRIPTION
* This routine implements the fill-in popup to get an integer
* value from the user. The box dimensions are determined on the
* fly depending upon the prompt length and the maximum allowable
* value. The height of the box is assumed to be 3. If an error
* is encountered during processing, that error is displayed with a
* beep and we return -1 with the ivalue remaining unchanged. If the
* user hits ESCAPE key then also -1 is returned (without changing
* the original ivalue) and the caller should take appropriate action
* (may be no action).
*
* SYNOPSIS
*
* PARAMETERS
* pn_row = Top row position
* pn_col = Left column position
* pc_prompt = Prompt message inside of the box
* pn_default = Starting value
* pn_low = Samllest permissible number
* pn_high = Largest permissible number
*
* LIMITATIONS
*
* DEPENDENCIES
*
*---------------------------------------------------------------------
PRIVATE ll_deli, ln_val, lc_pict, ln_inboxw, ln_rtn, lc_window, ;
ln_getcol
ll_deli = SET("DELIMITER") = "ON"
SET DELIMITER OFF
lc_window = WINDOW()
IF pn_high > 9999
lc_pict = "#####"
ELSE
IF pn_high > 999
lc_pict = "####"
ELSE
IF pn_high > 99
lc_pict = "###"
ELSE
IF pn_high > 9
lc_pict = "##"
ELSE
lc_pict = "#"
ENDIF
ENDIF
ENDIF
ENDIF
ln_pict = LEN( lc_pict )
*-- Inside width is length of prompt plus one space at front and
*-- two spaces after prompt plus the width of the picture template
ln_inboxw = LEN( pc_prompt ) + 3 + ln_pict
DEFINE WINDOW IntInBox FROM pn_row, pn_col ;
TO pn_row+2, pn_col+ln_inboxw DOUBLE
ACTIVATE WINDOW IntInBox
@ 0,0 SAY [ ] + pc_prompt + [ ]
ln_val = pn_default
ln_rtn = 0
ln_getcol = ln_inboxw - ln_pict - 1
DO WHILE .T.
@ 0, ln_getcol GET ln_val PICTURE (lc_pict)
DO _Read_It
ln_lastkey = LASTKEY()
DO CASE
CASE ln_lastkey = 27
ln_val = pn_default
ln_rtn = -1
EXIT
CASE ln_lastkey = 5 && Up arrow
ln_val = ln_val + 1
IF ln_val > pn_high
ln_val = pn_low
ENDIF
CASE ln_lastkey = 24 && Down arrow
ln_val = ln_val -1
IF ln_val < pn_low
ln_val = pn_high
ENDIF
OTHERWISE
IF ln_val >= pn_low .AND. ln_val <= pn_high
EXIT
ELSE
?? CHR(7)
ENDIF
ENDCASE
ENDDO
IF ln_rtn = 0
pn_default = ln_val
ENDIF
RELEASE WINDOW IntInBox
IF ll_deli
SET DELIMITER ON
ENDIF
SET CURSOR ON
IF .NOT. ISBLANK( lc_window )
ACTIVATE WINDOW &lc_window
ENDIF
RETURN( ln_rtn )
*-- EOF: _IntInBox( pn_row, pn_col, pc_prompt, pn_default, pn_low, pn_high )